package org.moonlight.jvm.instructions.math.bitoperate.shift;

import org.moonlight.jvm.instructions.base.NoOperandsInstruction;
import org.moonlight.jvm.rtda.exclusive.Frame;
import org.moonlight.jvm.rtda.exclusive.OperandStack;

/**
 * ISHR: 从 操作数栈 中弹出两个 int变量，进行 右移运算，然后把结果推入操作数栈。
 *
 * @author Moonlight
 * @createTime 2023/8/17 9:04
 **/
public class IShr extends NoOperandsInstruction {

    @Override
    public void execute(Frame frame) {
        OperandStack operandStack = frame.getOperandStack();

        int a = operandStack.popInt();
        int b = operandStack.popInt();
        int s = a & 0x1f;

        operandStack.pushInt( b >> s );
    }

}
